﻿/*
 * @author: wizardc
 */

using System;
using System.Collections.Generic;
using UnityEngine;

namespace DouEditor.Extend
{
    public class ShortcutData : ScriptableObject
    {
        public List<ShortcutConfig> shortcuts = new List<ShortcutConfig>();
    }
    
    [Serializable]
    public class ShortcutConfig
    {
        public string id;
        
        public string category;
        public string name;
        public string desc;
        
        public KeyCode keyCode;
        public bool control;
        public bool shift;
        public bool alt;
        
        public ShortcutConfig(string id, string category, string name, string desc, KeyCode keyCode, bool control, bool shift, bool alt)
        {
            this.id = id;
            this.category = category;
            this.name = name;
            this.desc = desc;
            this.keyCode = keyCode;
            this.control = control;
            this.shift = shift;
            this.alt = alt;
        }

        public string GetKeyString()
        {
            var result = "";
            if (control) result += "Ctrl+";
            if (shift) result += "Shift+";
            if (alt) result += "Alt+";
            result += keyCode.ToString();
            return result;
        }

        public bool IsPressed(Event currentEvent)
        {
            return currentEvent.keyCode == keyCode &&
                   currentEvent.control == control &&
                   currentEvent.shift == shift &&
                   currentEvent.alt == alt;
        }
    }
}
